<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${pageTitle != null ? pageTitle + ' - 管理后台' : '管理后台'}">管理后台</title>
    <link th:href="@{/admin/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/admin/css/bootstrap-icons.css}" rel="stylesheet">
    <link th:href="@{/admin/css/admin.css}" rel="stylesheet">
</head>
<body>
    <!-- 顶部导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" th:href="@{/admin}">
                <i class="bi bi-gear-fill me-2"></i>口语练习管理后台
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/admin}" th:classappend="${#request.requestURI == '/admin' ? 'active' : ''}">
                            <i class="bi bi-speedometer2 me-1"></i>仪表盘
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/admin/users}" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/users') ? 'active' : ''}">
                            <i class="bi bi-people me-1"></i>用户管理
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/admin/exam-papers}" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/exam-papers') ? 'active' : ''}">
                            <i class="bi bi-file-text me-1"></i>试卷管理
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/admin/classes}" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/classes') ? 'active' : ''}">
                            <i class="bi bi-building me-1"></i>班级管理
                        </a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/}" target="_blank">
                            <i class="bi bi-box-arrow-up-right me-1"></i>前台页面
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主内容区域 -->
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边栏 -->
            <div class="col-md-2 bg-light sidebar">
                <div class="position-sticky pt-3">
                    <ul class="nav nav-pills flex-column mb-auto">
                        <li class="nav-item">
                            <a th:href="@{/admin}" class="nav-link" th:classappend="${#request.requestURI == '/admin' ? 'active' : ''}">
                                <i class="bi bi-house-door me-2"></i>首页
                            </a>
                        </li>
                        <li class="nav-item">
                            <a th:href="@{/admin/users}" class="nav-link" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/users') ? 'active' : ''}">
                                <i class="bi bi-people me-2"></i>用户管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a th:href="@{/admin/exam-papers}" class="nav-link" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/exam-papers') ? 'active' : ''}">
                                <i class="bi bi-file-text me-2"></i>试卷管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a th:href="@{/admin/classes}" class="nav-link" th:classappend="${#strings.startsWith(#request.requestURI, '/admin/classes') ? 'active' : ''}">
                                <i class="bi bi-building me-2"></i>班级管理
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 页面内容 -->
            <main class="col-md-10 ms-sm-auto px-md-4">
                <!-- 消息提示 -->
                <div th:if="${message}" class="mt-3">
                    <div th:class="'alert alert-' + ${messageType == 'success' ? 'success' : 'danger'} + ' alert-dismissible fade show'" role="alert">
                        <span th:text="${message}"></span>
                        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                    </div>
                </div>

                <!-- 页面标题 -->
                <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                    <h1 class="h2" th:text="${pageTitle != null ? pageTitle : '管理后台'}">页面标题</h1>
                </div>

                <!-- 页面具体内容 -->
                <div th:replace="${content}">
                    页面内容将在这里显示
                </div>
            </main>
        </div>
    </div>

    <script th:src="@{/admin/js/bootstrap.bundle.min.js}"></script>
    <div th:replace="${scripts}"></div>
</body>
</html>